﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ajax.Models;

namespace Ajax.Controllers
{
    public class HomeController : Controller
    {
        //public ActionResult Index()
        //{
        //    ViewBag.Message = "Welcome to ASP.NET MVC!";

        //    return View();
        //}

        public ActionResult About()
        {
            return View();
        }

        public ActionResult Index()
        {
            return View(new Appointment());
        }
        [HttpPost]
        public ActionResult Index(Appointment app)
        {
            if (Request.IsAjaxRequest())
            {
                return Json(new
                {
                    ClientName = app.ClientName,
                    Date = app.Date.ToShortDateString(),
                    TermsAccepted = app.TermsAccepted
                });
            }
            else
            {
                return View();
            }
        }
    }
}
